//
//  YFCityPartnerHeaderView.m
//  QuanJieShopProject
//
//  Created by apple on 2018/5/26.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "YFCityPartnerHeaderView.h"

@interface YFCityPartnerHeaderView ()
@property (nonatomic, strong) UIView *bottomView;
@end

@implementation YFCityPartnerHeaderView

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor redColor];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self makeView];
    }
    return self;
}

- (void)makeView {
    

    // 头像
    UserInfoModel *model = [QJUserInfo getCurrentUser];
    UIImageView *userImgView = [[UIImageView alloc] init];
    [userImgView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",NET_BASEURL_IMG,model.avatar]] placeholderImage:[UIImage imageNamed:@"noHeaderImage"]];
    [self addSubview:userImgView];
    
    // 名字
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @"泉界商城";
    nameLabel.textColor = [UIColor whiteColor];
    nameLabel.font = [UIFont systemFontOfSize:17];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:nameLabel];
    
    // 今日收益 提示
    UILabel *incomeTipLabel = [[UILabel alloc] init];
    incomeTipLabel.text = @"今日收益(元)";
    incomeTipLabel.textColor = [UIColor whiteColor];
    incomeTipLabel.font = [UIFont systemFontOfSize:15];
    incomeTipLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:incomeTipLabel];
    
    // 今日收益
    UILabel *incomeLabel = [[UILabel alloc] init];
    incomeLabel.text = @"10.12";
    incomeLabel.textColor = [UIColor whiteColor];
    incomeLabel.font = [UIFont systemFontOfSize:50];
    incomeLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:incomeLabel];
    

    // bottomview
    UIView *bottomView = [[UIView alloc] init];
    bottomView.backgroundColor = [UIColor colorWithHexString:@"000000" alpha:0.2];
    [self addSubview:bottomView];
    self.bottomView = bottomView;
    
    [self setupBottomView];
    
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(50));
        make.bottom.left.right.equalTo(self);
    }];
    
    [incomeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).with.offset(-10);
        make.bottom.equalTo(self.bottomView.mas_top).with.offset(-10);
        make.width.equalTo(@(150));
        make.height.equalTo(@(70));
    }];
    
    [incomeTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(incomeLabel);
        make.bottom.equalTo(incomeLabel.mas_top).with.offset(-10);
        make.width.equalTo(@(150));
        make.height.equalTo(@(20));
    }];
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(100));
        make.height.equalTo(@(20));
        make.left.equalTo(self).with.offset(10);
        make.bottom.equalTo(self.bottomView.mas_top).with.offset(-10);
    }];
    
    [userImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@(80));
        make.left.equalTo(self).with.offset(10);
        make.bottom.equalTo(nameLabel.mas_top).with.offset(-10);
    }];
    
}

- (void)setupBottomView {
    
    UIImageView *arrowImgView = [[UIImageView alloc] init];
    arrowImgView.image = [UIImage imageNamed:@"Marrow"];
    [self.bottomView addSubview:arrowImgView];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.text = @"收益";
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.font = [UIFont systemFontOfSize:15];
    titleLabel.textAlignment = NSTextAlignmentRight;
    [self.bottomView addSubview:titleLabel];
    
    UIImageView *locationImgView = [[UIImageView alloc] init];
    locationImgView.image = [UIImage imageNamed:@"location"];
    [self.bottomView addSubview:locationImgView];
    
    UILabel *cityLabel = [[UILabel alloc] init];
    cityLabel.text = @"鄂州";
    cityLabel.textColor = [UIColor whiteColor];
    cityLabel.font = [UIFont systemFontOfSize:15];
    [self.bottomView addSubview:cityLabel];
    
    [arrowImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bottomView).with.offset(-10);;
        make.height.equalTo(@(15));
        make.width.equalTo(@(7));
        make.centerY.equalTo(titleLabel.mas_centerY);
    }];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.bottomView);
        make.right.equalTo(arrowImgView.mas_left).with.offset(-10);
        make.width.equalTo(@(100));
    }];
    
    [locationImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomView).with.offset(10);
        make.width.height.equalTo(@(20));
        make.centerY.equalTo(titleLabel.mas_centerY);
    }];
    
    [cityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.bottomView);
        make.left.equalTo(locationImgView.mas_right).with.offset(10);
        make.width.equalTo(@(50));
    }];
}

@end
